package cate.game.play.fighter;

import cate.game.play.skill.Skill;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import lombok.Data;

import java.util.HashSet;
import java.util.Set;

@NoteClass("战斗者的状态")
@Data
public class FighterStatus {

	@NoteField("觉醒状态")
	private boolean awaken = false;

	@NoteField(value = "提前选取的技能",detail = "")
	private Skill turnSkill;

	@NoteField(value = "行动忽略速度",detail = "")
	private boolean ignSpeedSort;

	@NoteField(value = "被标记为死亡",detail = "技能释放过程中不复活")
	private boolean markDead;

	@NoteField("允许驱散增益buff")
	private boolean allowDispelGood = true;

	@NoteField(value = "处于灵魂状态",detail = "无法被技能选中,无法添加buff,无法改变血量")
	private StatusRecord ghost = new StatusRecord();


	public boolean isGhost(){
		return ghost.enable();
	}


	public void onOwnerMoveOver() {
		turnSkill = null;
		ignSpeedSort = false;
	}


	public FighterStatus copy() {
		FighterStatus cp = new FighterStatus();
		cp.awaken = awaken;
		cp.turnSkill = turnSkill;
		cp.ignSpeedSort = ignSpeedSort;
		cp.markDead = markDead;
		cp.allowDispelGood = allowDispelGood;
		cp.ghost = ghost;
		return cp;
	}

	public static class StatusRecord {

		private Set<Integer> skills = new HashSet<>();

		private Set<Integer> buffs = new HashSet<>();

		public boolean enable() {
			return !skills.isEmpty() || !buffs.isEmpty();
		}

		public void addSkill(int tid) {
			skills.add(tid);
		}

		public boolean containSkill(int tid){
			return skills.contains(tid);
		}

		public void removeSkill(int tid) {
			skills.remove(tid);
		}

		public void addBuff(int tid) {
			buffs.add(tid);
		}

		public void removeBuff(int tid) {
			buffs.remove(tid);
		}

		public StatusRecord copy(){
			StatusRecord cp = new StatusRecord();
			cp.skills.addAll(this.skills);
			cp.buffs.addAll(this.buffs);
			return cp;
		}
	}
}
